/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.cezary.butler.walili.server.shuffling;

import java.util.Comparator;
import java.util.concurrent.atomic.AtomicBoolean;
import pl.cezary.butler.walili.client.utils.DomainComparator;
import pl.cezary.butler.walili.common.Task;



/**
 * Caution! Does not really meet contract
 * @author Czarek
 */
public class TaskShufflingComparator extends ShufflingComparator<Task> implements Comparator<Task> {
    
    private static final Comparator<Task> INSTANCE = new TaskShufflingComparator();    
    private static final Comparator<String> domainCom = DomainComparator.getInstance();    

    public TaskShufflingComparator(IShufflingIdGenerator gen) {
        super(gen);
    }

    private TaskShufflingComparator() {
        this(new ShufflingIdGenerator());
    }
    
    public static Comparator<Task> getInstance(){
        return INSTANCE;
    }             

    @Override
    protected boolean similarityTest(Task o1,Task o2) {
        return Math.abs(domainCom.compare(o1.getCelURL().getHost(), o2.getCelURL().getHost()))<10;
    }    
    
    
}
